from django.db import models


# Create your models here.


class DomainTopN(models.Model):
    datetime = models.DateTimeField(blank=False, null=False, verbose_name="请求时间")
    rank = models.PositiveSmallIntegerField(blank=False, null=False, verbose_name="排名")
    domain = models.CharField(max_length=128, null=False, verbose_name="域名")
    count = models.IntegerField(null=False, verbose_name="请求量")

    class Meta:
        db_table = "domain_topn"
        ordering = ['datetime']
        verbose_name = "DomainTopN"
        verbose_name_plural = verbose_name
        unique_together = (
            ('datetime', 'rank'),
        )


class NXDomainRate(models.Model):
    datetime = models.DateTimeField(primary_key=True, verbose_name="请求时间")
    total = models.IntegerField(null=False, verbose_name="总请求量")
    nxdomain_count = models.IntegerField(null=False, verbose_name="nxdomain请求量")
    rate = models.CharField(max_length=20, null=False, verbose_name="nxdomain比率")

    class Meta:
        db_table = "nxdomain_rate"
        ordering = ['datetime']
        verbose_name = "NXDomainRate"
        verbose_name_plural = verbose_name


class QPM(models.Model):
    datetime = models.DateTimeField(primary_key=True, verbose_name="请求时间")
    cache_1 = models.IntegerField(null=False, verbose_name="访问量1")
    cache_2 = models.IntegerField(null=False, verbose_name="访问量2")

    class Meta:
        db_table = "qpm"
        ordering = ['datetime']
        verbose_name = "qpm"
        verbose_name_plural = verbose_name
